/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package GUI;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.geom.*;
import Algorithm.*;
/**
 *
 * @author ErikLee
 */
public class Piece extends Ellipse2D.Double{
    //private BoardSquare _square;
    /**棋子的颜色和单击的颜色*/
    private Color _myColor;
    private boolean visible;
    private Point myPosition;
    private int mySize;
    private int mySide;

    public Piece(int x, int y, int aWidth , int side) {
        myPosition = new Point(x + 15, y + 15);
        mySize = aWidth - 30;
        //_square = aSquare;
        _myColor = Color.blue;
        visible = false;
        mySide = side;
    }

    public void setVisible(boolean displayState){
        visible = displayState;
    }

    public boolean getVisible(){
        return visible;
    }

    public void setColor(Color color){
        _myColor = color;
    }

    public Color getColor(){
        return _myColor;
    }

    public void setSide(int side){
        mySide = side;
    }

    public int getSide(){
        return mySide;
    }

    public void drawPiece(Graphics2D g){
        if (mySide == TicTacToe.HUMAN) {
            g.setColor(Color.cyan);
            g.setStroke(new BasicStroke(10));
            g.draw(new Ellipse2D.Double(myPosition.x, myPosition.y, mySize, mySize));
        }
        if (mySide == TicTacToe.COMPUTER) {
            g.setColor(Color.ORANGE);
            g.setStroke(new BasicStroke(10));
            g.draw(new Line2D.Double(myPosition.x, myPosition.y, myPosition.x + mySize, myPosition.y + mySize));
            g.draw(new Line2D.Double(myPosition.x + mySize, myPosition.y, myPosition.x, myPosition.y + mySize));
        }
    }

}
